<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:rich="http://richfaces.ajax4jsf.org/rich"
                template="layout/template.xhtml">
                       
<ui:define name="body">
    
    <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
    
    <h:form id="fileSearch" styleClass="edit">
    
        <rich:simpleTogglePanel label="File search parameters" switchType="ajax">
        
        
        </rich:simpleTogglePanel>
        
        <div class="actionButtons">
            <h:commandButton id="search" value="Search" action="/FileList.xhtml"/>
        </div>
        
    </h:form>
    
    <rich:panel>
        <f:facet name="header">File search results</f:facet>
    <div class="results" id="fileList">

    <h:outputText value="No file exists" 
               rendered="#{empty fileList.resultList}"/>
               
    <rich:dataTable id="fileList" 
                var="file"
              value="#{fileList.resultList}" 
           rendered="#{not empty fileList.resultList}">
       <h:column>
           <f:facet name="header">
               <s:link styleClass="columnHeader"
                            value="id #{fileList.order=='id asc' ? messages.down : ( fileList.order=='id desc' ? messages.up : '' )}">
                   <f:param name="order" value="#{fileList.order=='id asc' ? 'id desc' : 'id asc'}"/>
               </s:link>
           </f:facet>
           #{file.id}
       </h:column>
       <h:column>
           <f:facet name="header">
               <s:link styleClass="columnHeader"
                            value="title #{fileList.order=='title asc' ? messages.down : ( fileList.order=='title desc' ? messages.up : '' )}">
                   <f:param name="order" value="#{fileList.order=='title asc' ? 'title desc' : 'title asc'}"/>
               </s:link>
           </f:facet>
           #{file.title}
       </h:column>
       <h:column>
           <f:facet name="header">
               <s:link styleClass="columnHeader"
                            value="author id #{fileList.order=='author.id asc' ? messages.down : ( fileList.order=='author.id desc' ? messages.up : '' )}">
                   <f:param name="order" value="#{fileList.order=='author.id asc' ? 'author.id desc' : 'author.id asc'}"/>
               </s:link>
           </f:facet>
           #{file.author.id}
       </h:column>
       <h:column>
           <f:facet name="header">
               <s:link styleClass="columnHeader"
                            value="creationDate #{fileList.order=='creationDate asc' ? messages.down : ( fileList.order=='creationDate desc' ? messages.up : '' )}">
                   <f:param name="order" value="#{fileList.order=='creationDate asc' ? 'creationDate desc' : 'creationDate asc'}"/>
               </s:link>
           </f:facet>
           #{file.creationDate}
       </h:column>
        <h:column>
            <f:facet name="header">action</f:facet>
            <s:link view="/#{empty from ? 'File' : from}.xhtml" 
                   value="Select" 
                      id="file">
                <f:param name="fileId" 
                        value="#{file.id}"/>
            </s:link>
        </h:column>
    </rich:dataTable>

    </div>
    </rich:panel>
    
    <div class="tableControl">
      
        <s:link view="/FileList.xhtml" 
            rendered="#{fileList.previousExists}" 
               value="#{messages.left}#{messages.left} First Page"
                  id="firstPage">
          <f:param name="firstResult" value="0"/>
        </s:link>
        
        <s:link view="/FileList.xhtml" 
            rendered="#{fileList.previousExists}" 
               value="#{messages.left} Previous Page"
                  id="previousPage">
            <f:param name="firstResult" 
                    value="#{fileList.previousFirstResult}"/>
        </s:link>
        
        <s:link view="/FileList.xhtml" 
            rendered="#{fileList.nextExists}" 
               value="Next Page #{messages.right}"
                  id="nextPage">
            <f:param name="firstResult" 
                    value="#{fileList.nextFirstResult}"/>
        </s:link>
        
        <s:link view="/FileList.xhtml" 
            rendered="#{fileList.nextExists}" 
               value="Last Page #{messages.right}#{messages.right}"
                  id="lastPage">
            <f:param name="firstResult" 
                    value="#{fileList.lastFirstResult}"/>
        </s:link>
        
    </div>
    
    <s:div styleClass="actionButtons" rendered="#{empty from}">
        <s:button view="/FileEdit.xhtml"
                    id="create" 
                 value="Create file">
            <f:param name="fileId"/>
        </s:button>
    </s:div>
    
</ui:define>

</ui:composition>

